<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.yc.comm.Constant"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String strBtsName = request.getParameter("strBtsName");
String strChoosedTableId = request.getParameter("choosedTableId");
String choosedBtsName = request.getParameter("choosedBtsName");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <link rel="stylesheet" type="text/css" href="<%=path%>/js/ext/resources/css/ext-all.css">  
	<link rel="stylesheet" type="text/css" href="<%=path%>/js/ext/resources/css/edit-grid.css">   
	<script type="text/javascript" src="<%=path%>/js/ext/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="<%=path%>/js/ext/ext-all.js"></script>
	<script type="text/javascript" src="<%=path%>/js/ext/DWRTreeLoader.js"></script>
	<script type="text/javascript" src="<%=path%>/js/ext/SearchField.js"></script> 
	<script type="text/javascript" src="<%=path%>/js/ext/query-dwr-proxy.js"></script>	
	<script type='text/javascript' src="<%=path%>/dwr/engine.js"></script>
	<script type='text/javascript' src="<%=path%>/dwr/util.js"></script> 
	<script type='text/javascript' src="<%=path%>/dwr/interface/JStorageBatteryWeb.js"></script>
    <title>蓄电池</title>  

  </head>
  
<body>
<form id="backForm" method="POST" action="<%=path%>/pages/query/query.jsp">
	<input type="hidden" name="choosedTableId" id="choosedTableId_ID" value="<%=strChoosedTableId%>"/>
	<input type="hidden" name="choosedBtsName" id="choosedBtsName_ID" value="<%=choosedBtsName%>"/>
</form>
<div id="mainTabPanelDIV" style="width:100%;height:100%"></div>
<script>
Ext.onReady(function(){  
	Ext.QuickTips.init();
	
	var viewport = new Ext.Viewport({
	    layout:'border',
	    frame:true,
	    items:[ 
	    	{
		        region: 'center',
		        contentEl: 'mainTabPanelDIV',
		        margins:'110 30 30 5',
		        split: true,
		        border: true	
		    }]
		});

	var storageBatteryType = Ext.data.Record.create([								
	                  							   {name: 'id', type: "string"},
	                  							   {name: 'btscode', type: "string"},
	                  							   {name: 'btsname', type: "string"},
	                  							   {name: 'type', type: "string"},
	                  							   {name: 'manufacturer', type: "string"},
	                  							   {name: 'capacity', type: "string"},
	                  							   {name: 'groupnum', type: "string"},
	                  							   {name: 'batterynum', type: "string"},
	                  							   {name: 'voltage', type: 'string'},
	                  							   {name: 'opentime', type: 'date'},
	                  							   {name: 'discharge',  type: 'string'},
	                  							   {name: 'maintenance',  type: 'string'},
	                  							   {name: 'refreshtime',  type: 'date'},
	                  							   {name: 'memo',  type: 'string'}
	                  						 ]);
       	var storageBatteryCM = new Ext.grid.ColumnModel(
       			[	            
       				{header: "流水号", sortable: true, dataIndex: 'id',align:'left'},
       				{header: "基站编号", sortable: true, dataIndex: 'btscode',align:'left'},
       				{header: "基站名称",  sortable: true, dataIndex: 'btsname',align:'left'},	
       				{header: "规格型号",  sortable: true, dataIndex: 'type',align:'left'},	
       				{header: "容量",  sortable: true, dataIndex: 'capacity',align:'left'},	
       				{header: "厂家",  sortable: true, dataIndex: 'manufacturer',align:'left'},	
       				{header: "电池组数",  sortable: true, dataIndex: 'groupnum',align:'left'},	 
       				{header: "启用日期",  width: 150,sortable: true, renderer: Ext.util.Format.dateRenderer('Y-m-d'),dataIndex: 'opentime',align:'left'},	 
       				{header: "启用日期",  width: 150,sortable: true, renderer: Ext.util.Format.dateRenderer('Y-m-d'),dataIndex: 'refreshtime',align:'left'}
       								
       			]
       		);		
   	var storageBatteryDS = new Ext.data.Store({
		proxy: new Ext.data.DWRProxy(JStorageBatteryWeb.getStorageBatteryByBtsName, true),	
		reader: new Ext.data.ListRangeReader({
			totalProperty: 'totalSize',
			id: 'id'
		}, storageBatteryType),
		sortInfo:{field:'id', direction:'ASC'}// 排序信息
	});
   	var gridDiv = Ext.get("mainTabPanelDIV");
	var grid = new Ext.grid.GridPanel({			
			el:'mainTabPanelDIV', 	
			ds: storageBatteryDS,
			cm: storageBatteryCM,  
			autoWidth : true,  
			autoScroll : true,  
			autoHeight　: false, 
			height: gridDiv.getComputedHeight(), 
			minSize: 200,		
			frame:true,
			collapsible:false, 
			enableDragDrop:false, 	
			tbar: new Ext.Toolbar(
					[
						{xtype:"tbfill"}, 
						{
				 			text:'返回',
				 			pressed:true,					 
				            handler:function()// 点击按钮执行的操作
				            {
								document.getElementById("backForm").submit();
				            }
				        }
					]),	
			bbar: new Ext.PagingToolbar({
					pageSize: 17,
					store: storageBatteryDS,
					displayInfo: true,
					displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
					emptyMsg: "没有记录"
				})
		});	
	storageBatteryDS.on('beforeload', function() 
	{
		storageBatteryDS.baseParams = {'<%=Constant.BTS_NAME%>':'<%=strBtsName%>'};
	});
	storageBatteryDS.load({params:{start:0,limit:17,'<%=Constant.BTS_NAME%>':'<%=strBtsName%>'}});
	grid.render();		
		
})		

</script>
</body>
</html>
